package org.heydr.common.filter.impl;

import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;

import org.heydr.annotation.FilterMapping;
import org.heydr.common.filter.Filter;
import org.heydr.common.http.StringUtils;

@FilterMapping(name="md5")
public class MD5Filter implements Filter{
	
	private static Set<String> md5Set = new ConcurrentSkipListSet<String>();
	
	public boolean contains(String value){
		String md5 = StringUtils.md5(value);
		return md5Set.contains(md5);
	}
	
	public boolean remove(String value){
		String md5 = StringUtils.md5(value);
		return md5Set.remove(md5);
	}
	
	public synchronized void add(String value){
		String md5 = StringUtils.md5(value);
		md5Set.add(md5);
	}
	
}
